using System;
using System.Collections.Generic;
using System.Text;


using System.Net;
using System.IO;


namespace svnBackup
{
    public class util
    {

        public static string GetPage(string url)
        {
            WebResponse response = null;
            Stream stream = null;
            StreamReader  reader = null;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                response = request.GetResponse();
                stream = response.GetResponseStream();

                if (!response.ContentType.ToLower().StartsWith("text/"))
                    return null;

                string buffer = "", line;

                reader = new StreamReader(stream);

                while ((line = reader.ReadLine()) != null)
                {
                    buffer += line + "\r\n";
                }

                return buffer;
            }
            catch (WebException e)
            {
                System.Console.WriteLine("Can't download:" + e);
                return null;
            }
            catch (IOException e)
            {
                System.Console.WriteLine("Can't download:" + e);
                return null;
            }
            finally
            {
                if (reader != null)
                    reader.Close();

                if (stream != null)
                    stream.Close();

                if (response != null)
                    response.Close();
            }
        } // end of getpage




      

    }
}
